#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2018, Intel Corporation
#
#
# pmempool_create/TEST3 -- test for inheriting pools
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type pmem non-pmem

setup

POOL=$DIR/file.pool
INHERIT=$DIR/inherit.pool

# PMEMBLK
expect_normal_exit $PMEMPOOL$EXESUFFIX create blk 512 $POOL
check_file $POOL
check_signature PMEMBLK $POOL
SIZE=$(get_size $POOL)
expect_normal_exit $PMEMPOOL$EXESUFFIX create --inherit $POOL $INHERIT
check_file $INHERIT
check_signature PMEMBLK $INHERIT
check_size $SIZE $INHERIT

# PMEMLOG
rm -f $POOL
rm -f $INHERIT
expect_normal_exit $PMEMPOOL$EXESUFFIX create log $POOL
check_file $POOL
check_signature PMEMLOG $POOL
SIZE=$(get_size $POOL)
expect_normal_exit $PMEMPOOL$EXESUFFIX create --inherit $POOL $INHERIT
check_file $INHERIT
check_signature PMEMLOG $INHERIT
check_size $SIZE $INHERIT

# PMEMOBJ
rm -f $POOL
rm -f $INHERIT
expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=LAYOUT_NAME$SUFFIX obj $POOL
check_file $POOL
check_signature PMEMOBJ $POOL
check_layout LAYOUT_NAME$SUFFIX $POOL
SIZE=$(get_size $POOL)
expect_normal_exit $PMEMPOOL$EXESUFFIX create --inherit $POOL $INHERIT
check_file $INHERIT
check_signature PMEMOBJ $INHERIT
check_layout LAYOUT_NAME$SUFFIX $POOL
check_size $SIZE $INHERIT

pass
